<template>
  <div id="app">
    <Header v-if="isHeaderShow" id="headWrapper"></Header>
    <router-view class="main-content"></router-view>
    <el-backtop class="backtop" target="#app" title="回到顶部"></el-backtop>
  </div>
</template>
<script>
import Header from '_c/Header.vue'
export default {
  name: 'App',
  components: {
    Header
  },
  computed: {
    // 根据当前的路由的路径名来判断
    isHeaderShow() {
      let routerNameList = ['Error_401', 'Error_404', 'Error_500']
      return routerNameList.includes(this.$route.name) ? false : true
    },

  },
  mounted() {
    //监听窗口改变情况，调用store里面的函数
    const that = this
    window.addEventListener('resize', function () {
      return (() => {
        that.$store.commit('changeScreenWidth', document.body.clientWidth)
      })()
    })
  }
}
</script>
<style lang="stylus" scoped>
@import '~_a/styles/varibles.styl';

#app {
  height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: none;
  overflow-y: auto;
  >>> .el-backtop {
    background-color: $Success;
    color: #fff;
    z-index: 3;
  }
  .main-content {
    flex: 1;
    width: 90%;
    min-height: calc(100vh - 70px);
    margin: 0 auto;
    display: flex;
  }
}
</style>
